package com.imu.purse.modules.app.dao;

import java.util.List;
import org.apache.ibatis.annotations.Select;
import com.imu.purse.modules.app.entity.RateEntity;
import com.imu.core.base.BaseMapper;

/**
 * 
 * @author sunhongwei
 * @email sunhongwei@jshijian.com
 * @date 2018-04-03 15:46:50
 * Copyright (c) 2017 武汉极时间科技有限公司 版权所有 
 * Jshijian aloha CO.,LTD. All Rights Reserved. 
 */
public interface RateMapper extends BaseMapper<RateEntity>
{
	/**
     * 分页查询
     * @param pageNo 页号
     * @param pageSize 每页显示记录数
     * @return
     */
	@Select({
		"<script>",
		    "SELECT id,",
					"min_val, ",
					"max_val, ",
					"rate, ",
					"time_create, ",
					"time_update, ",
					"create_user, ",
					"update_user, ",
					"enabled_flag",
		    "FROM imu_rate ",
		    "WHERE 1=1",
			"<when test = 'minVal != null'>",
		    	"AND `min_val` = #{minVal}",
		    "</when>",
			"<when test = 'maxVal != null'>",
		    	"AND `max_val` = #{maxVal}",
		    "</when>",
			"<when test = 'rate != null'>",
		    	"AND `rate` = #{rate}",
		    "</when>",
			"<when test = 'timeCreate != null'>",
		    	"AND `time_create` = #{timeCreate}",
		    "</when>",
			"<when test = 'timeUpdate != null'>",
		    	"AND `time_update` = #{timeUpdate}",
		    "</when>",
			"<when test = 'createUser != null'>",
		    	"AND `create_user` = #{createUser}",
		    "</when>",
			"<when test = 'updateUser != null'>",
		    	"AND `update_user` = #{updateUser}",
		    "</when>",
			"<when test = 'enabledFlag != null'>",
		    	"AND `enabled_flag` = #{enabledFlag}",
		    "</when>",
		    "ORDER BY id DESC",
    	"</script>"
	})
    public List<RateEntity> findByPage(final RateEntity entity);
	
	/**
     * 分页查询
     * @param pageNo 页号
     * @param pageSize 每页显示记录数
     * @return
     */
	@Select({
		"<script>",
		    "SELECT id,",
					"min_val, ",
					"max_val, ",
					"rate, ",
					"time_create, ",
					"time_update, ",
					"create_user, ",
					"update_user, ",
					"enabled_flag",
		    "FROM imu_rate ",
		    "WHERE 1=1",
		    	"AND #{rate} <![CDATA[  >=  ]]> `min_val`  ",
		    	"AND #{rate} <![CDATA[   <=  ]]> `max_val`  ",
    	"</script>"
	})
    public RateEntity selectByRate(final RateEntity entity);
}
